import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/10 22:16
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            String s = sc.nextLine();
            if (s.length() < 8 || lowThree(s)) {
                System.out.println("NG");
            }else {
                // 长度维度
                boolean repeat = false;
                for (int i = 3; i < s.length(); i++) {
                    Set<String> set = new HashSet<>();
                    for (int j = 0; j + i <= s.length(); j++) {
                        if (!set.add(s.substring(j, i + j))) {
                            System.out.println("NG");
                            repeat = true;
                            break;
                        }
                    }
                    if (repeat) {
                        break;
                    }
                }
                if (!repeat) {
                    System.out.println("OK");
                }
            }
        }
    }

    private static boolean lowThree(String s) {
        int type = 0;
        for (char c: s.toCharArray()) {
            if (Character.isDigit(c) ) {
                type |= 1;
            }else if (Character.isLowerCase(c) ) {
                type |= 2;
            }else if (Character.isUpperCase(c)) {
                type |= 4;
            }else {
                type |= 8;
            }
        }
        return type < 7;

    }
}
